<?php

/**
 * 内容关联的门店列表
 * Class RelatedListAction
 */

use Biz\service\Store\StoreBasicService;
use Doraemon\tools\IdParse;
use Biz\tools\Location;


class RelatedListAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

    /**
     * @throws Exception
     */
    public function main()
    {
        $obj_id = $this->getRequest()->getPost('obj_id') ?? 0;
        if (!$obj_id ) {
            throw new \Exception("obj_id 为空！");
        }
        $data = ['count' => 0 , 'list' => []];
        $ObjUid = IdParse::getUid($obj_id);
        $location = new Location($this->uid);
        $showStore = $location->isShowStore();
        if (($this->uid == $ObjUid && $this->uid > 0) || $showStore) {
            $store_list =  StoreBasicService::getRelStoreListByObjId($obj_id);
            $data = ['count' => count($store_list) ,'list' => $store_list ];
        }
        return $this->setSuccess($data);
    }


}